fix: detect esm only pkg w/ main and module fields#1494
fix: detect esm only pkg w/ main and module fields#1494ghostdevv merged 1 commit intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThe changes modify the module format detection logic in Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. Comment |
|
Thanks for your first contribution, @jonchurch! 💪 We'd love to welcome you to the npmx community. Come and say hi on Discord! And once you've joined, visit npmx.wamellow.com to claim the contributor role. |
Problem
In the Compare feature, the heuristic for legacy fallback for dual vs esm only detection has a bug currently where it assumes
maincontains CJS when the package also has amodulefield.That reports ESM only packages w/ both esm main and module fields like lodash-es as dual packages.
Above is an ESM only package description, but currently that will be reported as "ESM + CJS"
Solution
Infer if the main field should be CJS or ESM. If main is
.cjsextension then we for sure know it's CJS. If we have a.jsfile and no"type": "module"then we have a CJS file.📸
Before:

After:
